<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // POST请求，body传参
        fetch("http://nocat.life:3021/product/find", {
            method: 'POST',
            // 配置请求头headers
            headers: {
                // Content-Type：告诉后端前端发送的数据是json格式
                "Content-Type": "application/json"
            },
            // 配置请求体
            body: JSON.stringify({
                pageSize: 5
            })
        })
            .then(res => res.json())
            .then(res => {
                // console.log("结果", res);
            })

        // GET请求，问号Query传参
        fetch("http://nocat.life:3021/product/find?pageSize=5&currentPage=1", {
            method: 'GET',
        })
            .then(res => res.json())
            .then(res => {
                // console.log("结果", res);
            })


        // 路径参数（不限请求类型）
        fetch('http://nocat.life:3021/product/detail/682c0f3f47bd398e5f05fd06', {
            method: 'GET'
        })
            .then(response => response.json())
            .then(res => {
                // console.log("结果", res);
            })



        getProductDetail();
        async function getProductDetail() {
            const response = await fetch('http://nocat.life:3021/product/detail/682c0f3f47bd398e5f05fd06', {
                method: 'GET'
            })
            const res = await response.json();
            console.log("结果", res);
        }

        
    </script>
</body>

</html>